package io.renren.modules.app.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.app.req.BalanceLogReq;
import io.renren.modules.app.utils.AuthUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.app.dao.BalanceLogDao;
import io.renren.modules.app.entity.BalanceLogEntity;
import io.renren.modules.app.service.BalanceLogService;


@Service("balanceLogService")
public class BalanceLogServiceImpl extends ServiceImpl<BalanceLogDao, BalanceLogEntity> implements BalanceLogService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BalanceLogEntity> page = this.page(
                new Query<BalanceLogEntity>().getPage(params),
                new QueryWrapper<BalanceLogEntity>().eq("user_id",1)
        );
        return new PageUtils(page);
    }

    @Override
    public PageUtils balanceLogPage(IPage<BalanceLogEntity> page,BalanceLogEntity balanceLogEntity) {
        IPage<BalanceLogEntity> pages = baseMapper.selectPage(page,new QueryWrapper<BalanceLogEntity>().eq("user_id",1));
//        //查询缴费记录
//        PayOrderRecord payOrderRecord = baseMapper.selectOne(new QueryWrapper<PayOrderRecord>().lambda().eq(PayOrderRecord::getOutTradeNo, outTradeNo));
        return new PageUtils(pages);
    }

    @Override
    public PageUtils selectBalanceLogPage(IPage<BalanceLogEntity> page, BalanceLogEntity balanceLogEntity) {
         page.setRecords(baseMapper.selectBalanceLogPage(page,balanceLogEntity));
        return new PageUtils(page);
    }
    /**
     *用户个人余额
     * @param page
     * @param balanceLogReq
     * @return
     */
    @Override
    public PageUtils getBalanceLog(Page page, BalanceLogReq balanceLogReq) {
        balanceLogReq.setUserId(AuthUtils.getUserId());
        page.setRecords(baseMapper.getBalanceLog(page,balanceLogReq));
        return new PageUtils(page);
    }
}